const request = require('../../utils/request.js')
Page({
  data:{
    all:{},
    shopMes:{},
    today:{},
    markers:{},
    starUrl:'../../images/star.png',
    starLightUrl:'../../images/starlight.png'
  },
  onShow:function(){
    if (wx.getStorageSync('shopID')) {
      request(['/store/getstoremessage', 'POST', { 
        shopID: wx.getStorageSync('shopID')
        }],
        res=>{
          if(res.code===1){
            console.log(res.data)
            const { all,shopMes,today } = res.data;
            this.setData({ 
              all, 
              shopMes, 
              today, 
              markers:[{
                latitude: shopMes.latitude,
                longitude: shopMes.longitude
                }]
              })
          }
          if(res.code===0){
            this.loginOut()
          }
      })
    }
  },

  loginOut:function(){
    wx.clearStorageSync()
    wx.navigateTo({
      url: '/pages/login/index',
    })
  }
})